﻿/*
 *
 * @author
 * @version
 */
import com.mixmedia.motion.MotionTween;
class gui.McContentHolder extends MovieClip{
	private var motion;
	private var overMotion;
	private var nowRootSection;
	
	public function McContentHolder(){
		motion = new MotionTween(this,{dur:20});
		overMotion = new MotionTween(_parent.overContent_mc,{dur:20});
	}

	public function onLoad(){//because in same frame.
		_global.mainNavigation.addEventListener("onSectionChange",mx.utils.Delegate.create(this,swapSection));
		_root.bgmVol.addEventListener("onFadeout",mx.utils.Delegate.create(this,updateSound));
	}

	public function swapSection(evt){
		//TO DO:split behaviour;
		nowRootSection = Number(evt.value.split('_')[0]);
		motion.startTween({x:-778*nowRootSection});
		overMotion.startTween({x:-778*nowRootSection});

		var fileFolder = ["intro/","promo/","artist/","company/"];
		var filePath = fileFolder[nowRootSection]+evt.value.split('_')[1]+"/";
		switch (nowRootSection){
			case 0:
				_root.bgmVol.fadeout();
				break;
			case 1:
				_root.bgmVol.fadeout();
				this["content"+nowRootSection].swapImage(evt.value+".swf",filePath);
				break;
			case 2:
				_root.bgmVol.fadeout();
				this["content"+nowRootSection].swapImage(evt.value+".swf",filePath);
				break;
			case 3:
				_root.bgmVol.fadeout();
				this["content"+nowRootSection].swapImage(evt.value+".swf",filePath);
				break;
		}
	}
	private function updateSound(){
		var tmpArray = [_root.bgm,_root.promoBgm,_root.artistBgm];
		for(var i=0;i<tmpArray.length;i++){
			tmpArray[i].stop();
		}
		tmpArray[nowRootSection].start();
		tmpArray[nowRootSection].setVolume(100);
		_root.bgmVol.fadein();
	}
}